<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version = "1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:param name = "status" />
<xsl:template match = "/">
<html>
<head>
<title>Гостевая книга</title>
<script type = "text/javascript" src = "js/main.js">
</script>
<script type = "text/javascript" src = "js/sort.js">
</script>
</head>
<body>
<div id = "pageLayout">
<div id = "status">
<xsl:choose>
<xsl:when test = "$status = 'added'">
<h1>Добавлено</h1>
</xsl:when>
<xsl:when test = "$status = 'not_added'">
<h1>ошибка при добавлении</h1>
</xsl:when>
</xsl:choose>
</div>
<div id = "new_message">
<xsl:call-template name = "new_message" />
</div>
<div id = "messages">
<xsl:call-template name = "records" />
</div>
</div>
</body>
</html>
</xsl:template>

<!-- Вывод сообщений гостевой книги -->
<xsl:template name = "records">
<xsl:choose>
<xsl:when test = "rows/noRecords">
<h1>Нет записей!</h1>
</xsl:when>
<xsl:otherwise>
<form action = "" method = "post" id = "sort_form">
<input type = "hidden" name = "sort" id = "s" />
<input type = "hidden" name = "sort_mode" id = "s_m" />
</form>
<table>
<tr>
<th>id</th>
<th>автор (<a onclick = "sort ('sort_user', 'asc');">А-Я</a> | <a onclick = "sort ('sort_user', 'desc');">Я-А</a>)</th>
<th>E-mail (<a onclick = "sort ('sort_mail', 'asc');">А-Я</a> | <a onclick = "sort ('sort_mail', 'desc');">Я-А</a>)</th>
<th>Homepage url</th>
<th>message</th>
<th>ip</th>
<th>user agent</th>
<th>Date (<a onclick = "sort ('sort_date', 'asc');">А-Я</a> | <a onclick = "sort ('sort_date', 'desc');">Я-А</a>)</th>
</tr>
<xsl:for-each select = "rows/row">
<tr>
<td>
<xsl:value-of select = "id" />
</td>
<td>
<xsl:value-of select = "user_name" />
</td>
<td>
<xsl:value-of select = "email" />
</td>
<td>
<xsl:value-of select = "home_page" />
</td>
<td>
<xsl:value-of select = "message" />
</td>
<td>
<xsl:value-of select = "ip" />
</td>
<td>
<xsl:value-of select = "browser" />
</td>
<td>
<xsl:value-of select = "message_date" />
</td>
</tr>
</xsl:for-each>
</table>
</xsl:otherwise>
</xsl:choose>
</xsl:template>

<!--  Форма добавления сообщения -->
<xsl:template name = "new_message">
<form action = "" method = "post">
<img src = "captcha.php" />
</form>
</xsl:template>
</xsl:stylesheet>